﻿using System;
using System.IO;
using System.Threading.Tasks;

class SimpleFileCopy
{
    static void Main(string[] args)
    {
        Console.WriteLine("开始多线程文件拷贝...\n");

        string sourcePath = @"D:\Source";
        string destPath = @"D:\Destination";

      
        Directory.CreateDirectory(destPath);

      
        string[] allFiles = Directory.GetFiles(sourcePath);

        
        Parallel.ForEach(allFiles, file =>
        {
            string destFile = Path.Combine(destPath, Path.GetFileName(file));
            File.Copy(file, destFile, true);
            Console.WriteLine($"已拷贝: {Path.GetFileName(file)}");
        });

        Console.WriteLine($"\n完成! 共拷贝 {allFiles.Length} 个文件");
        Console.ReadKey();
    }
}